import { defineStore } from 'pinia';

interface Team {
  id: string
  thumbnail: string
  name: string
  description: string
  admin: string
  openness: string
  member_count: number
  access: string
  projects?: {
    id: number
    title: string
    description: string
    favorites: number
    isPublic: boolean
  }[]
}

interface TeamState {
  teams: Team[]
  currentTeam: Team | null
  error: string | null
  currentUser: string | null
}

export const useTeamStore = defineStore('team', {
  state: (): TeamState => ({
    teams: [],
    currentTeam: null,
    error: null,
    currentUser: null,
  }),
  actions: {
    // 设置当前团队
    setCurrentTeam(team: any) {
      this.currentTeam = team
    },
    // 重置
    resetCurrentTeam() {
      this.currentTeam = null
      this.error = null
    },

  },
});
